<?php

$pdo = new PDO('mysql:dbname=atm;charset=UTF8','root');

$pdo -> beginTransaction();//开起事件源，防止安全隐患

$pdo -> prepare('update user set money=money+200 where id=1') -> execute();

die;

$pdo -> prepare('update user set money=money-200 where id=2') -> execute();

$pdo -> commit();//检查数据没有出错以后才提交数据

var_dump($pdo);
